package com.ps.dao.salary;

import java.sql.Timestamp;
import java.util.List;
import org.hibernate.LockMode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.ps.pojo.salary.SalarySetOfBooksItem;

/**
 * A data access object (DAO) providing persistence and search support for
 * SalarySetOfBooksItem entities. Transaction control of the save(), update()
 * and delete() operations can directly support Spring container-managed
 * transactions or they can be augmented to handle user-managed Spring
 * transactions. Each of these methods provides additional information for how
 * to configure it for the desired type of transaction control.
 * 
 * @see com.ps.pojo.salary.SalarySetOfBooksItem
 * @author MyEclipse Persistence Tools
 */

public class SalarySetOfBooksItemDAO extends HibernateDaoSupport {
	private static final Logger log = LoggerFactory
			.getLogger(SalarySetOfBooksItemDAO.class);
	// property constants
	public static final String SSOB_ID = "ssobId";
	public static final String NAME = "name";
	public static final String MONEY = "money";
	public static final String ACCURACY = "accuracy";
	public static final String FORMULA = "formula";
	public static final String ENABLE = "enable";
	public static final String REAMRK = "reamrk";
	public static final String INPUTER_ID = "inputerId";

	protected void initDao() {
		// do nothing
	}

	public void save(SalarySetOfBooksItem transientInstance) {
		log.debug("saving SalarySetOfBooksItem instance");
		try {
			getHibernateTemplate().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(SalarySetOfBooksItem persistentInstance) {
		log.debug("deleting SalarySetOfBooksItem instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public SalarySetOfBooksItem findById(java.lang.Integer id) {
		log.debug("getting SalarySetOfBooksItem instance with id: " + id);
		try {
			SalarySetOfBooksItem instance = (SalarySetOfBooksItem) getHibernateTemplate()
					.get("com.ps.pojo.salary.SalarySetOfBooksItem", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(SalarySetOfBooksItem instance) {
		log.debug("finding SalarySetOfBooksItem instance by example");
		try {
			List results = getHibernateTemplate().findByExample(instance);
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding SalarySetOfBooksItem instance with property: "
				+ propertyName + ", value: " + value);
		try {
			String queryString = "from SalarySetOfBooksItem as model where model."
					+ propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List findBySsobId(Object ssobId) {
		return findByProperty(SSOB_ID, ssobId);
	}

	public List findByName(Object name) {
		return findByProperty(NAME, name);
	}

	public List findByMoney(Object money) {
		return findByProperty(MONEY, money);
	}

	public List findByAccuracy(Object accuracy) {
		return findByProperty(ACCURACY, accuracy);
	}

	public List findByFormula(Object formula) {
		return findByProperty(FORMULA, formula);
	}

	public List findByEnable(Object enable) {
		return findByProperty(ENABLE, enable);
	}

	public List findByReamrk(Object reamrk) {
		return findByProperty(REAMRK, reamrk);
	}

	public List findByInputerId(Object inputerId) {
		return findByProperty(INPUTER_ID, inputerId);
	}

	public List findAll() {
		log.debug("finding all SalarySetOfBooksItem instances");
		try {
			String queryString = "from SalarySetOfBooksItem";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public SalarySetOfBooksItem merge(SalarySetOfBooksItem detachedInstance) {
		log.debug("merging SalarySetOfBooksItem instance");
		try {
			SalarySetOfBooksItem result = (SalarySetOfBooksItem) getHibernateTemplate()
					.merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public void attachDirty(SalarySetOfBooksItem instance) {
		log.debug("attaching dirty SalarySetOfBooksItem instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(SalarySetOfBooksItem instance) {
		log.debug("attaching clean SalarySetOfBooksItem instance");
		try {
			getHibernateTemplate().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public static SalarySetOfBooksItemDAO getFromApplicationContext(
			ApplicationContext ctx) {
		return (SalarySetOfBooksItemDAO) ctx.getBean("SalarySetOfBooksItemDAO");
	}
}